package com.sgq.vue.dao.picture;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.sgq.vue.entity.picture.Picture;
import com.sgq.vue.vo.query.picture.PictureQueryVo;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author: 83778
 * @date: 2024-01-04 17:38
 * @desc:
 */
@Mapper
public interface PictureMapper extends BaseMapper<Picture> {


    @Update("update picture_picture set tags = #{tags} where id = #{pictureId}")
    int updateTagsById(@Param("pictureId") Long pictureId,@Param("tags") String tags);

    /**
     * 删除不管is_delete是0还是1的图片
     * @param ids
     * @return
     */
    @Delete("<script> DELETE FROM picture_picture WHERE id in <foreach collection='ids' item='id' open='(' separator=',' close=')'>#{id}</foreach> </script>")
    Integer realDeleteByIds(@Param("ids") List<Long> ids);

    /**
     * 查询不管is_delete是0还是1的图片地址
     * @param ids
     * @return
     */
    @Select("<script> SELECT url FROM picture_picture WHERE id in <foreach collection='ids' item='id' open='(' separator=',' close=')'>#{id}</foreach> </script>")
    List<String> realSelectUrlByIds(@Param("ids") List<Long> ids);

    @Select("select * from picture_picture where is_deleted=1 ")
    List<Picture> selectAllIsNotRealDeleted();

    List<Picture> selectIsNotRealDeletedByPage(@Param("queryVo")PictureQueryVo queryVo);

    Long selectCountByLike(@Param("queryVo")PictureQueryVo queryVo);

    /**
     * 恢复删除状态至未删除状态
     * @param id
     * @return
     */
    @Update("update picture_picture set is_deleted=0 where id= #{id}")
    Integer recover(@Param("id") Long id);


}
